/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pointfinder;

import computing.Configurator;
import com.jme3.math.Vector2f;
import com.jme3.terrain.geomipmap.TerrainQuad;
import data.Vector3i;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author oxplay
 */
public class TerrainContainer extends AbstractPointContainer {

    private TerrainQuad terrain;

    public TerrainContainer(TerrainQuad terrain) {
        this.terrain = terrain;
    }

    public PointEntity getPoint(Vector3i vect) {
        if (Math.abs(terrain.getHeight(new Vector2f(vect.x, vect.z)) - vect.y) < Configurator.PRECISION_OFFSET) {
            return PointEntity.MOVEABLE;
        }
        return PointEntity.NEUTRAL;
    }

    @Override
    public ArrayList<Vector3i> getAllPoints() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Deprecated
    @Override
    public Set<data.Vector3i> getPointsSection(Vector3i from, Vector3i to) {
        Set<Vector3i> list = new HashSet<Vector3i>();
        for (int x = from.x; x < to.x; x++) {
            for (int z = from.z; z < to.z; z++) {
                list.add(new Vector3i(x, Configurator.getFloatToIntValue(terrain.getHeight(new Vector2f(Configurator.getIntToFloatValue(x), Configurator.getIntToFloatValue(z)))), z));
            }
        }
        return list;
    }
}
